package com.snake.springboot.custom.controller.aicost;

import com.snake.springboot.custom.api.model.aicost.GeneratePayModel;
import com.snake.springboot.custom.api.response.aicost.GenerateCheckRsp;
import com.snake.springboot.custom.api.service.aicost.GeneratePayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.snake.common.result.ResponseResult;
import org.snake.common.result.ResponseResultFactory;
import org.snake.common.validate.Create;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>生成支付
 * 类{@code GeneratePay} </br>
 * 创建时间2025/3/21 10:31
 *
 * @author yangxt
 * @see
 */
@Api(tags = "生成支付")
@RestController
@RequestMapping("/generate-pay")
public class GeneratePayController {

    private GeneratePayService generatePayService;
    @Autowired
    public GeneratePayController(GeneratePayService generatePayService) {
        this.generatePayService = generatePayService;
    }

    @ApiOperation("校验")
    @PostMapping("/check")
    public ResponseResult<GenerateCheckRsp> check(
            @ApiParam(name = "接口入参", value = "传入json格式", required = true)
            @RequestBody @Validated({Create.class}) GeneratePayModel model) {
        GenerateCheckRsp result = generatePayService.check(model);
        return ResponseResultFactory.ucc("校验成功！", result);
    }

    @ApiOperation("支付")
    @PostMapping("/pay")
    public ResponseResult<GeneratePayModel> pay(
            @ApiParam(name = "接口模型入参", value = "传入json格式", required = true)
            @RequestBody GeneratePayModel model) {
        generatePayService.pay(model);
        return ResponseResultFactory.ucc("支付成功！");
    }
}
